package com.my.xq.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;

import com.my.xq.domain.entity.ProprietorAuth;
import com.sskj.core.repository.GenericRepository;

public interface ProprietorAuthRepository extends GenericRepository<ProprietorAuth, String> {

	@Query(value = " select auth from ProprietorAuth a where a.delFlag = 0 and a.doorplateId = ?1 ")
	public String isAuth(String doorId);

	@Query(value = " select a from ProprietorAuth a where a.delFlag = 0 and a.doorplateId = ?1 ")
	public ProprietorAuth findByDoorId(String doorId);

	@Query(value = " select"
			+ " a.id as proprietorAuthId "
			+ " , a.authorizer as authorizer "
			+ " , a.doorplateId as doorplateId "
			+ " , a.proprietorId as proprietorId "
			+ " , a.auth as auth "
			+ " , p.name as name "
			+ " , p.identityCard as idNo "
			+ " , p.phone as phone "
			+ " , p.gender as gender "
			+ " from ProprietorAuth a, Proprietor p where a.doorplateId = ?1 and a.delFlag = 0 and a.proprietorId = p.id ")
	public List<Object[]> findProprietorAndAuthByDoorId(String doorId);
}
